package net.jitc.registers;

import java.util.ArrayList;

/**
 * @Author admin
 * @Date 2019/4/2 14:49
 */
public class UserDaoimp implements UserDao {
    ArrayList<User> arrayList = new ArrayList<User>();

    @Override
    public void rgister(User user) {
        arrayList.add(user);
        System.out.println("注册成功！");
    }

    @Override
    public boolean login(String name, String password) {
        for (int i = 0; i <arrayList.size() ; i++) {
            if (arrayList.get(i).getName().equals(name)&&arrayList.get(i).getPassword().equals(password)){
                return true;
            }
        }
        return false;
    }

    @Override
    public void search(String name) {
        for (int i = 0; i <arrayList.size() ; i++) {
            User user=arrayList.get(i);
            if (user.getName().equals(name)){
                System.out.println("该用户信息为："+user);
                return;
            }
        }
        System.out.println("不存在该用户！");
    }

    @Override
    public void checkAll() {

    }
}
